package com.qhy.service.imp;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.qhy.mapper.TbLetterMapper;
import com.qhy.mapper.ViewLetMapper;
import com.qhy.pojo.ViewLet;
import com.qhy.pojo.ViewLetExample;
import com.qhy.pojo.ViewLetExample.Criteria;
import com.qhy.service.ILetterService;

@Service
public class LetterService implements ILetterService {
	
	@Resource
	private ViewLetMapper mapper;
	
	@Resource
	private TbLetterMapper letterMapper;

	public List<ViewLet> queryByRecId(Integer rec_id) {
		ViewLetExample example = new ViewLetExample();
		Criteria criteria = example.createCriteria();
		criteria.andLeUsRecipientsidEqualTo(rec_id);
		return mapper.selectByExample(example);
	}

	public List<ViewLet> queryByRecIdAndStastu(Integer rec_id) {
		ViewLetExample example = new ViewLetExample();
		Criteria criteria = example.createCriteria();
		criteria.andLeUsRecipientsidEqualTo(rec_id);
		criteria.andLeStastuEqualTo(0);
		return mapper.selectByExample(example);
	}

	public int readLet(Integer le_id) {
		ViewLetExample example = new ViewLetExample();
		Criteria criteria = example.createCriteria();
		criteria.andLeIdEqualTo(le_id);
		ViewLet viewLet = new ViewLet();
		viewLet.setLeStastu(1);
		return mapper.updateByExampleSelective(viewLet, example);
	}

	public int deleteLet(Integer le_id) {
		return letterMapper.deleteByPrimaryKey(le_id);
	}
	
	
	
	
	
	
	
}
